<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\User;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '团购列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="groupbuy-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <?php  echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [


            'id',
            ['attribute'=>'user1','value'=>function($model){
                $user = User::findOne($model->user1);
                return $user->nickname;
            }],
            ['attribute'=>'user1','value'=>function($model){
                $user = User::findOne($model->user1);
                return $user->phone;
            },'header'=>'手机号'],
//            ['attribute'=>'users','format'=>'raw','value'=>function($model){
//                $result='';
//                $users= json_decode($model->users,true);
//                foreach($users as $user){
//                    $result.=Html::img($user['avatar']);
//                    $result.=" 昵称：".$user['nickname'].'手机号：'.$user['phone'].'<br>';
//                }
//                return $result;
//            }],
//            'goodsid',
            'createtime',
            'endtime',
            ['attribute'=>'status','value'=>function($model){
                return $model->status?'拼团成功':'拼团中';
            }],

            ['class' => 'yii\grid\ActionColumn','template'=>'{view}{delete}'],
        ],
    ]); ?>
</div>
